package com.lingmeng.common.core.utils;

import java.time.LocalDateTime;
import java.time.ZoneId;

public class LocalDateTimeUtils {
	public static String YYYY = "yyyy";

	public static String YYYY_MM = "yyyy-MM";

	public static String YYYY_MM_DD = "yyyy-MM-dd";

	public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";

	public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";

	private static String[] parsePatterns = {
			"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
			"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
			"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};


	private static final ZoneId TIME_ZONE = ZoneId.of("Asia/Shanghai");

	/**
	 * 获取当前时间戳
	 * @return 时间戳
	 */
	public static long localDateTimeToTimestamp(){
		return localDateTimeToTimestamp(LocalDateTime.now());
	}

	/**
	 * LocalDateTime 转 时间戳
	 * @param localDateTime 指定时间
	 * @return 时间戳
	 */
	public static long localDateTimeToTimestamp(LocalDateTime localDateTime) {
		return localDateTime.atZone(TIME_ZONE).toInstant().toEpochMilli();
	}



}
